package com.qyhl.shop.shop.center.shop;

import com.qyhl.shop.common.ShopUrl;
import com.qyhl.webtv.basiclib.utils.network.EasyHttp;
import com.qyhl.webtv.basiclib.utils.network.callback.SimpleCallBack;
import com.qyhl.webtv.basiclib.utils.network.exception.ApiException;
import com.qyhl.webtv.commonlib.common.CommonUtils;
import com.qyhl.webtv.commonlib.entity.shop.ShopListBean;

import java.util.List;

public class ShopCenterShopListModel implements ShopCenterShopListContract.ShopCenterShopListModel {
    private ShopCenterShopListPresenter mPresenter;

    public ShopCenterShopListModel(ShopCenterShopListPresenter mPresenter) {
        this.mPresenter = mPresenter;
    }

    @Override
    public void getList(String phoneNum, int page) {
        EasyHttp.post(ShopUrl.SHOP_CENTER_SHOP)
                .params("siteId", CommonUtils.getInstance().getSite() + "")
                .params("phoneNum", phoneNum)
                .params("page", page + "")
                .execute(new SimpleCallBack<List<ShopListBean>>() {
                    @Override
                    public void onError(ApiException e) {
                        mPresenter.setError("获取关注列表失败！");
                    }

                    @Override
                    public void onSuccess(List<ShopListBean> beanList) {
                        mPresenter.setList(beanList);
                    }
                });
    }
}
